package DataAccessLayerFactory;
use YAML;
use DataAccessLayer;

sub new {
	my $self = {};
	bless $self;
	return $self;
}

sub load_config {    
    my $config_file = shift;
    my @array_hashref = YAML::LoadFile($config_file);
    if (!@array_hashref){
            return(undef, "The configuration file is in wrong format")
    }else{
        my $dbconf = $array_hashref[0];		
        return ($dbconf, "Successfully loaded"); 
    } 	
}

sub load_data_access_layer_from_yaml_file{
    my $self = shift;
    my $config_file = shift;
    my ($dbconf,$msg) = DataAccessLayerFactory::load_config($config_file);
    if (!$dbconf){
        return(undef, "Can't load data configuration")
    }else{
        my $dal = DataAccessLayer::new();
        #print Data::Dumper::Dumper($dbconf);
        $dal->url($dbconf->{url});
        $dal->user($dbconf->{user});
        $dal->password($dbconf->{password});            
        return ($dal, "Successfully loaded"); 
    } 	
}

sub DESTROY{
	
}
 
1;